home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 845 b | 55 lines | [TEXT/CWIE] |
- package com.metrowerks;
-
- import java.awt.*;
- import java.applet.Applet;
-
- public class AppletFrame extends Frame
- {
- public static void startApplet( String className,
- String title, String args[])
- {
- Applet a;
- Dimension appletSize;
-
- try {
- a = (Applet)
- Class.forName(className).newInstance();
- } catch (ClassNotFoundException e) {
- return;
- } catch (InstantiationException e) {
- return;
- } catch (IllegalAccessException e) {
- return;
- }
-
- a.init();
- a.start();
-
- AppletFrame f = new AppletFrame(title);
-
- f.add("Center", a);
-
- appletSize = a.size();
- f.pack();
- f.resize(appletSize);
- f.show();
-
- }
-
- public AppletFrame(String name)
- {
- super(name);
- }
-
- public boolean handleEvent(Event e)
- {
- if (e.id == Event.WINDOW_DESTROY)
- {
- dispose();
- return true;
- }
-
- return super.handleEvent(e);
- }
- }
-